import instance from '@/http/index.ts'
import type {getDepartmentMsgForm,clickDeleteForm,changeUserReadListForm,changeUserReadListButDeleteForm} from './type.ts'
//统一管理接口
enum API {
    getDepartmentMsg_url = '/dm/getDepartmentMsg',
    getDepartmentMsgList_url = '/dm/getDepartmentMsgList',
    getReadListAndStatus_url = '/dm/getReadListAndStatus',
    clickDelete_url = '/dm/clickDelete',
    changeUserReadList_url = '/dm/changeUserReadList',
    changeUserReadListButDelete_url = '/dm/changeUserReadListButDelete',

}
// 获取部门消息 id list 
export const getDepartmentMsg = (data:getDepartmentMsgForm) => {
    return instance.post(API.getDepartmentMsg_url,data)
}
// 获取部门消息
export const getDepartmentMsgList = (department:string | null) => {
    return instance.post(API.getDepartmentMsgList_url,{department})
}
// 返回用户的阅读列表及状态
export const getReadListAndStatus = (id:string | number) => {
    return instance.post(API.getReadListAndStatus_url,{id})
}
// 用户点击消息后,对read_list内的数据进行删减
export const clickDelete = (data:clickDeleteForm) => {
    return instance.post(API.clickDelete_url,data)
}
// 把新发布文章的id插入到当前所属部门的用户的read_list中
export const changeUserReadList = (data:changeUserReadListForm) => {
    return instance.post(API.changeUserReadList_url,data)
}
// 把删除的文章的id从当前所属部门的用户的read_list中删除
export const changeUserReadListButDelete = (data:changeUserReadListButDeleteForm) => {
    return instance.post(API.changeUserReadListButDelete_url,data)
}